#include <iostream>

#include "routines.h"
#include <string.h>


using namespace std;


void showUsage(){

    std::cout << "Usage: <--modeNumber=0/1/2>" << std::endl;
    std::cout << "./ProgramName modeNumber " << std::endl;
    std::cout << "modeNumber=0. 自动运行求逆的测试程序" << std::endl;
    std::cout << "modeNumber=1. 自动运行求解的测试程序 " << std::endl;
    std::cout << "modeNumber=2. 从文件中，读取矩阵和x求解 " << std::endl;

}

int main(int argc, char *argv[]){


    

#ifdef DEBUG
    test_swap(4); // 对行变换进行单元测试
#endif

    if(argc < 2){
        showUsage();
    }

    int modeNumber;

    if(strncmp(argv[1], "--modeNumber=", 13)){
        modeNumber = (int)(argv[1][0] - '0');
    }
    else showUsage();

    printf("modeNumber = %d\n", modeNumber);

    switch(modeNumber){
        case 0: {
            for(int i = 4; i < 500; i*=2){
                std::cout<<"size = "<<i;
                if(test_GetReverseA(i)) std::cout<<"test_GetReverseA pass!-----"<<std::endl;
                else std::cout<<"error"<<std::endl;
            }
            break;
        }
        case 1: {
            for(int i = 4; i < 1000; i*=2){
                std::cout<<"size = "<<i;
                if(test_solve(i)) std::cout<<"test_solve pass!-----"<<std::endl;
                else std::cout<<"error"<<std::endl;
            }
            break;
        }
        case 2: {
            std::string filepath = "/text/in.txt";
            std::cout<<"please in put file path"<<std::endl;
            std::cin>>filepath;
            matrixFromIntxt(filepath);
            break;
        }
    }

    // matrixFromIntxt(); // 从文件In.txt中读取矩阵

    return 0;
}